#ifndef __VSDL_TEXT_H__
#define __VSDL_TEXT_H__

#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#include <string>
#include "VSDL_point.h"

//Font styles
#define FONT_STYLE_NORMAL		TTF_STYLE_NORMAL
#define FONT_STYLE_BOLD			TTF_STYLE_BOLD
#define FONT_STYLE_ITALIC		TTF_STYLE_ITALIC
#define FONT_STYLE_UNDERLINE		TTF_STYLE_UNDERLINE
#define FONT_STYLE_STRIKETHROUGH	TTF_STYLE_STRIKETHROUGH

//Font Render Modes
#define FONT_RENDER_MODE_SOLID		0x0
#define FONT_RENDER_MODE_SHADED		0x1
#define FONT_RENDER_MODE_BLENDED	0x2
//Font text code
#define FONT_CODE_NORMAL		0x0
#define FONT_CODE_UTF8			0x1
#define FONT_CODE_UNICODE		0x2

namespace VSDL_FontSystem{
	int InitFontSystem();
	int FontSystemReady();
	void CloseFontSystem();
}

class VSDL_Font{
private:
	bool initFlag;
	int style;
	int fontSize;
	TTF_Font *font;
	std::string fontFile;
public:
	VSDL_Font();
	VSDL_Font(std::string &fontFileName, int fontSize);
	VSDL_Font(const char *fontFileName, int fontSize);
	~VSDL_Font();
	int LoadFont(const char *fontFileName, int fontSize);
	int SetStyle(int style);
	int SetFontSize(int size);
	bool FontInitialized();
	bool FontInitialized() const;
	SDL_Surface *GetSurface(const char *text, int renderMode, int encode, SDL_Color fgColor, SDL_Color bgColor);
	int GetTextSize(int encode, const char *text, int *textWidth, int *textHeight);
};

class VSDL_Text{
private:
	std::string msg;
	int renderMode;
	int encode; //NORMAL UTF8 UNICODE
	VSDL_Font *currentFont;	
	int msgWidth;
	int msgHeight;
	SDL_Surface *msgSurf;
	SDL_Color fgColor;
	SDL_Color bgColor;
public:
	VSDL_Text();
	VSDL_Text(VSDL_Font *font);
	VSDL_Text(VSDL_Font *font, const std::string &text);
	VSDL_Text(VSDL_Font *font, const char *text);
	~VSDL_Text();
	void SetFont(VSDL_Font *font);
	void SetEncode(int encode);
	void SetRenderMode(int renderMode);
	void SetFgColor(unsigned char r, unsigned char g, unsigned char b);
	void SetFgColor(SDL_Color color);
	void SetBgColor(unsigned char r, unsigned char g, unsigned char b);
	void SetBgColor(SDL_Color color);
	void SetText(const std::string &text);
	void SetText(const char *text);	
	const char *GetText();
	void GetTextSize(int *textWidth, int *textHeight);
	//Use when applying font properties
	void UpdateFont();
	void Blit(SDL_Surface *destSurf, int destX, int destY);
	void Blit(SDL_Surface *destSurf, VSDL_Point point);
	friend void TextChange(VSDL_Text &text);
};

#endif /*__VSDL_TEXT_H__*/
